import {createWebHistory,createRouter} from "vue-router";
import index from "@/components/index.vue";
import UserInformation from "@/components/Page/UserInformation.vue";
import Login from "@/components/Login.vue";
import StockTransfer from "@/components/Page/StockTransfer.vue";
import Daily from "@/components/Page/Daily.vue";
import Monthly from "@/components/Page/Monthly.vue";
import StockInfo from "@/components/Page/StockInfo.vue";
import Orders from "@/components/Page/Orders.vue";

const router = createRouter({
  history: createWebHistory(),
  routes: [
    {
      path: "/index",
      name: "index",
      component: index,
      // 添加重定向到默认子路由
      redirect: "/index/user",
      children: [
        {
          path: "userInformation",
          name: "userInformation",
          component: UserInformation,
        },
      ],
    },
      //仓库管理
    {
      path: "/warehouse",
      name: "warehouse",
      component:index,
      redirect: "/warehouse/stockTransfer",
      children: [
        {
          path: "stockTransfer",
          name: "stockTransfer",
          component: StockTransfer,
        }
      ],
    },
      //订单记录
    {
      path: "/order",
      name: "order",
      component:index,
      redirect: "/order/all",
      children: [
        {
          path: "all",
          name: "all",
          component: Orders,
        },
        {
          path: "daily",
          name: "daily",
          component: Daily,
        },
        {
          path: "monthly",
          name: "monthly",
          component: Monthly,
        }
      ],
    },
      //余货信息
    {
      path: "/stock",
      name: "stock",
      component:index,
      redirect: "/stock/info",
      children: [
        {
          path: "info",
          name: "stockInfo",
          component: StockInfo,
        }
      ],
    },
    {
      path: "/login",
      name: "login",
      component: Login,
    },
    {
      path: "/",
      redirect: "/login"
    }
  ],
});
export default router;